<?php
 
function getNextClosureDate($currentDate) {
	$connection = mysqli_connect("localhost", "root"); 
	$dataBase = mysqli_select_db($connection, "projectcosts");
	$nextClosure = NULL;
	$currentDateDivision = explode ("-", $currentDate);
	$currentDay = $currentDateDivision[0];
	$currentMonth = $currentDateDivision[1];
	$currentYear = $currentDateDivision[2];
	
	$query = "SELECT firstclosure FROM months";
	$result = mysqli_query($connection, $query); 
	$i = 0;
		while ($row = mysqli_fetch_array($result)) {
			$dateDivision = explode ("-", $row['firstclosure']);
			$day[$i] = $dateDivision[2];
			$month[$i] = $dateDivision[1];
			
			
			$i++;
		}
	
	$nextClosure = $day[(int)$currentMonth] . "-" . ($currentMonth + 1) . "-" . $currentYear;		
	return date("d-m-Y", strtotime($nextClosure));	
	
}

?>